import api from './index'
import request from "../utils/request";


export function searchAnswerer (userId,name) {
  const data = {userId:userId,queryStr:name}
  return request({
    url: api.searchAnswererByKey,
    method: "post",
    data
  })
}

export function addAnswerer (userId,answererName,answererPassword,answererTele,scQuestion,scAnswer) {
  const data = {
    userId:userId,
    username:answererName,
    password:answererPassword,
    telnumber:answererTele,
    securityQuestionContext:scQuestion,
    securityQuestionAnswer:scAnswer
  }
  return request({
    url: api.addAnswerer,
    method: "post",
    data
  })
}

export function modifyAnswerer (answererId,answererName,answererTele,scQ,scA) {
  const data = {
    id:answererId,
    username:answererName,
    telnumber:answererTele,
    securityQuestionContext:scQ,
    securityQuestionAnswer:scA
  }
  return request({
    url: api.modifyAnswerer,
    method: "post",
    data
  })
}

export function deleteAnswerer (answererId) {
  const data = {id:answererId}
  return request({
    url: api.deleteAnswerer,
    method: "post",
    data
  })
}

export function addAnswererToGroup (answererNameArray,groupName) {
  const data = {answererNameArray:answererNameArray,groupName:groupName}
  return request({
    url: api.addAnswererToGroup,
    method: "post",
    data
  })
}

export function downTemplate(){
  const data = {}
  return request({
    url: api.downloadTemplate,
    method: "post",
    data
  })
}

export function uploadAnswererData(formData){
  return request({
    url: api.uploadAnswererData,
    method: "post",
    data: formData
  })
}
